import { APILX } from '@/api/requestLx'
import { getDictModel } from '@/api/goodsManagement'
import { ajaxGetDictItems } from '@/api/api'
export let columns = [
  {
    title: '盘点单号',
    dataIndex: 'inventoryCode',
    ellipsis: true,
    fixed: 'left',
    width: 200,
    searchIndex: 'inventoryCode',
    scopedSlots: {
      filterDropdown: 'searchDropdown',
      filterIcon: 'searchIcon',
      customRender: 'inventoryCode',
    },
  },
  {
    title: '盘点仓库',
    dataIndex: 'warehouseName',
    ellipsis: true,
    fixed: 'left',
    width: 180,
    searchIndex: 'warehouseId',
    options: [],
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'inventoryType',
    },
  },
  {
    title: '盘点人',
    dataIndex: 'inventoryUser',
    width: 180,
    ellipsis: true,
    scopedSlots: {
      customRender: 'inventoryUser',
    },
  },
  {
    title: '盘点类型',
    dataIndex: 'inventoryTypeTxt',
    ellipsis: true,
    width: 180,
    searchIndex: 'inventoryType',
    options: [],
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'inventoryType',
    },
  },
  {
    title: '审批状态',
    dataIndex: 'flowStatusText',
    ellipsis: true,
    width: 120,
    searchIndex: 'flowStatus',
    options: [],
    multi: true,
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'flowStatus',
    },
  },
  {
    title: '盘点状态',
    dataIndex: 'inventoryStatusTxt',
    ellipsis: true,
    width: 120,
    searchIndex: 'inventoryStatus',
    options: [],
    multi: true,
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'inventoryStatus',
    },
  },
  // {
  //   fixed: 'right',
  //   title: '操作',
  //   align: 'left',
  //   dataIndex: 'actions',
  //   width: 150,
  //   scopedSlots: { customRender: 'actions' },
  // },
]
export let allColumn = [
  {
    title: '盘点单号',
    dataIndex: 'inventoryCode',
    ellipsis: true,
    fixed: 'left',
    width: 200,
    searchIndex: 'inventoryCode',
    scopedSlots: {
      filterDropdown: 'searchDropdown',
      filterIcon: 'searchIcon',
      customRender: 'inventoryCode',
    },
  },
  {
    title: '盘点仓库',
    dataIndex: 'warehouseName',
    ellipsis: true,
    fixed: 'left',
    width: 180,
    searchIndex: 'warehouseId',
    options: [],
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'inventoryType',
    },
  },
  {
    title: '盘点人',
    dataIndex: 'inventoryUser',
    width: 180,
    ellipsis: true,
    scopedSlots: {
      customRender: 'inventoryUser',
    },
  },
  {
    title: '盘点类型',
    dataIndex: 'inventoryTypeTxt',
    ellipsis: true,
    width: 180,
    searchIndex: 'inventoryType',
    options: [],
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'inventoryType',
    },
  },
  {
    title: '审批状态',
    dataIndex: 'flowStatusText',
    ellipsis: true,
    width: 120,
    searchIndex: 'flowStatus',
    options: [],
    multi: true,
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'flowStatus',
    },
  },
  {
    title: '盘点状态',
    dataIndex: 'inventoryStatusTxt',
    ellipsis: true,
    width: 120,
    searchIndex: 'inventoryStatus',
    options: [],
    multi: true,
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'dateIcon',
      customRender: 'inventoryStatus',
    },
  },
]
export function getTypeList() {
  let parametersType = { dictCode: 'inventory_type' }
  ajaxGetDictItems('erp_apply_status').then((res) => {
    if (res.result) {
      let newArrApply = res.result.map((item) => {
        return {
          label: item.title,
          key: item.value,
        }
      })
      columns[4].options = newArrApply
      allColumn[4].options = newArrApply
    }
  })
  getDictModel(parametersType).then((res) => {
    if (res.success) {
      let newArr = res.result.map((item) => {
        return {
          label: item.title,
          key: item.value,
        }
      })
      columns[3].options = newArr
      allColumn[3].options = newArr
    } else {
      this.$antdMessage.warning(res.message)
    }
  })
  APILX.warehouseInventoryGetStatusList().then((res) => {
    if (res.success) {
      let newArrStatus = res.result.map((item) => {
        return {
          label: item.title,
          key: item.value,
        }
      })
      columns[5].options = newArrStatus
      allColumn[5].options = newArrStatus
    } else {
      this.$antdMessage.warning(res.message)
    }
  })
  APILX.wmsWarehouseQueryList().then((res) => {
    if (res.code == 200) {
      let newArrStatus = res.result.map((item) => {
        return {
          label: item.title,
          key: item.value,
        }
      })
      columns[1].options = newArrStatus
      allColumn[1].options = newArrStatus
      console.log(newArrStatus,"0.0.0.0.0.0.0")
    } else {
      that.$antdMessage.error(res.message)
    }
  })
}
